CMScript is a Contextual Menu Plugin that runs AppleScripts on the "context".
CMScript is not going to be a separate product until the end of time. Plans are that it will be integrated with a future version of Leonard Rosenthol's "OSA Menu" (see <http://www.lazerware.com/~leonardr/>).
Installation
Put the two plugins, CMScript and ContextGrabber, and the "Contextual Menu Scripts" folder into the "Contextual Menu Items" folder inside the System Folder.
What it does
What does it do with the scripts in the "Contextual Menu Scripts" folder?
Wherever you are CMScript takes into account scripts found in two subfolders: “Universal Scripts” and “<Application Name> Scripts” (e.g. “Finder Scripts”).
When you activate the Contextual Menu by holding down the control key and clicking the mouse CMScript scans these folders for scripts. For each found script it checks if it applies to the context.
How it works (technically — skip if you like)
To facilitate finding out if a script applies to the context scripts must tell what kind of data they understan: the first line (or rather paragraph as it might be wrapped) of the script's description is used for this purpose. Put the type code of the data your script can operate on there. CMScript determines if the context can be made into the desired data type or a list of items of that type. For some types you can specify even more:
fss TEXTttxt - only SimpleText text documents
fss TEXT - any text document
fss ****ttxt - any SimpleText document
reco - any record
recopnme - a record containing a name (= «class pnam») property and possibly others.
recopnamldt - dito + a date (= «class ldt ») property.
You can check for "object specifiers" (sorry for the jargon):
obj cfol - folders (only in the Finder)
If a script is applicable to the context its filename is put into the CM. When a script is chosen from the CM its "open"-handler gets called with the context data as a list (possibly having only one element) of items of the desired type.
How do I find out what the context is?
Now, the description above may have been just a bit too technical. Here's the easy way. :-)
Use the included "ContextGrabber" Module to find out about the context:
If caps lock is pressed during a context-click ContextGrabber does several things:
• It adds a menu item "Make Template Script". This command puts a script file on your desktop that's already preconfigured somewhat to be useful in the currently selected context. Remember to save it as a compiled script if you want to use it from the CMScript!
• It adds an item to "Copy Context to Clipboard" with the submenu items "Easy" and "Advanced".
"Advanced" is only suited for hardcore AppleEvent freaks, they'll get output from AEPrint (and understand what this means for them).
"Easy" is something suitable for use as a desired context (first line of the script's description) in your own scripts. One special case is that this plugin does not take file objects to be objects, i.e. "obj file", but treats them as file specifications. Thus you'd get the more helpful "fss TEXTttxt" if you selected a SimpleText text document.
In case of trouble
• Make sure you have only one "Contextual Menu Extension" installed. This can be a problem in particular on non-US systems as some software installers may install a duplicate US-copy on such a system (a case in point apparently is/was "Apple Data Detectors").
• CMScript only displays your scripts in the Finder and a few other applications? Well, the reason is that only very few applications actually support the Contextual Menu yet. But you can get around this by installing "Apple Data Detectors" (look for it on <http://applescript.apple.com>). Among other things this will give you the "Contextual Menu Enabler" extension that will enable the contextual menu in virtually any application.
A Note of Caution: If you use "Contextual Menu Enabler" 1.0.2 (or newer) you'll find that it adds a menu item "Turn on Contextual Menus in app name " to the Help menu of some applications. These are applications that don't support the CM directly. If you turn on the CM in such an app be sure to quit and relaunch it before using the CM for the first time. This is not strictly necessary, but may avoid trouble in some cases.
Please tell me about your problems so I can do something about them or add them here.
Version History
1.0.2 Added special treatment of record specifiers in context description.
1.0.1 First public version.
1.0 Not released.
Disclaimer
You might have guessed it already, but I take no responsibility for the consequences for anything CMScript does to your computer. If you think this is unacceptable, just don't use it.
That's it for now. I appreciate any bug reports and suggestions. Have as much fun with this thingie as possible.